﻿#region using statements

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

using NGen;
using NGen.Managers.GUI;
using NGen.Managers.GameState;
using NGen.Managers.Input;

using Psych.GUILayouts;

#endregion

namespace Psych.States
{
    internal delegate void ForwardDrawEvent(GameTime p_gameTime);

    public class GameStatePause : GameState, IKeyboardListener
    {
        private readonly GUIElementSettings m_window = new GUIElementSettings();

        #region IKeyboardListener Members

        public void KeyPressed(Keys p_key)
        {
            switch (p_key)
            {
                case Keys.Escape:
                    GameEngine.GetService<IManagerGameState>().PopState();
                    break;
            }
        }

        public void KeyReleased(Keys p_key) { }

        #endregion

        internal event ForwardDrawEvent ThrowDrawEvent;

        protected override void _Cleanup()
        {
            GameEngine.GetService<IManagerGUI>().RemoveElement(m_window);
        }

        protected override void _Draw(GameTime p_gameTime)
        {
            ThrowDrawEvent(p_gameTime);
        }

        protected override void _Initialize()
        {
            GameEngine.GetService<IManagerGUI>().AddElement(m_window);
        }

        protected override void _OnFocusGained()
        {
            GameEngine.GetService<IManagerInput>().AddKeyboardListener(this);
        }

        protected override void _OnFocusLost()
        {
            GameEngine.GetService<IManagerInput>().RemoveKeyboardListener(this);
        }

        protected override void _Update(GameTime p_gameTime) { }
    }
}